﻿using System;

namespace RayDen.Library.Components {
    public static class DirectionDiscretizationHelper {
        static float[] costheta = new float[256];
        static float[] sintheta = new float[256];
        static float[] cosphi = new float[256];
        static float[] sinphi = new float[256];

        static DirectionDiscretizationHelper() {
            for (int i = 0; i < 256; i++) {
                double a = i * (1.0d / 256.0d) * Math.PI;
                costheta[i] = (float)Math.Cos(a);
                sintheta[i] = (float)Math.Sin(a);
                cosphi[i] = (float)Math.Cos(2.0d * a);
                sinphi[i] = (float)Math.Sin(2.0d * a);
            }
        }

        public static float CosPhi(byte c) {
            return cosphi[c];
        }

        public static float SinPhi(byte c) {
            return sinphi[c];
        }

        public static float CosTheta(byte c) {
            return costheta[c];
        }

        public static float SinTheta(byte c) {
            return sintheta[c];
        }
    }
}